<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
<head th:include="template::head">

</head>
<body class="hold-transition skin-red layout-top-nav" ng-app="pls">
<div class="wrapper">
    <navigation th:include="template::header">

    </navigation>
    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">

        <section class="content-header">
            <h1>
                <span>任务管理</span>
            </h1>
        </section>

        <!-- Main content -->
        <section class="content">
            <!-- Your Page Content Here -->
            <div class="row" ng-controller="fzldInterfaceTaskController">
                <div class="col-xs-12">
                    <div class="box box-primary">
                        <div class="box-header with-border">
                            <h3 class="box-title" th:text="#{action.searchTitle}">查询</h3>
                        </div>
                        <!-- /.box-header -->
                        <div class="box-body">
                            <div class='row'>
                                <div class='col-md-3'>
                                    <div class="form-group">
                                        <label for="idSearch_name" class="control-label">描述</label>
                                        <input entersearch="true" type="text" id="idSearch_name" ng-model="search.name" class="form-control" th:placeholder="描述"/>
                                    </div>
                                </div>
                                <div class='col-md-3'>
                                    <div class="form-group">
                                        <label for="idSearch_taskType" class="control-label">任务类型</label>
                                        <input entersearch="true" type="text" id="idSearch_taskType" ng-model="search.taskType" class="form-control" th:placeholder="任务类型"/>
                                    </div>
                                </div>
                                <div class='col-md-3'>
                                    <div class="form-group">
                                        <label for="idSearch_taskSource" class="control-label">发起方</label>
                                        <input entersearch="true" type="text" id="idSearch_taskSource" ng-model="search.taskSource" class="form-control" th:placeholder="任务来源"/>
                                    </div>
                                </div>
                                <div class='col-md-3'>
                                    <div class="form-group">
                                        <label for="idSearch_taskFunction" class="control-label">存储过程</label>
                                        <input entersearch="true" type="text" id="idSearch_taskFunction" ng-model="search.function" class="form-control" th:placeholder="调用函数"/>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!-- /.box-body -->

                        <div class="box-footer" id="buttons">
                            <button class="btn btn-primary" id="searchButton"
                                    th:text="#{action.search}"
                                    ng-click="doSearch($event)">Search</button>
                            <button class="btn btn-danger"
                                    th:text="#{action.clear}"
                                    ng-click="resetSearch($event)">Clear</button>
                            <button class="btn btn-success"
                                    th:text="#{action.import}"
                                    ng-click="importShow($event)"></button>
                            <button class="btn btn-warning pull-right"
                                    ng-click="exportImportExcel()">下载导入模板</button>
                        </div>

                        <div class="box-body">
                            <table id="tableResult" class="table table-bordered table-hover">
                                <thead>
                                <tr>
                                     <th class="sorting">
                                            <span th:text="任务类型" style="width: 160px"></span>
                                            <span class="pull-right"><i id="id_sort_icon_asnNo" class="fa fa-fw fa-sort" ng-click="sortBy('taskType')"></i></span>
                                    </th>
                                    <th class="sorting">
                                        <span th:text="描述"></span>
                                        <span class="pull-right"><i id="id_sort_icon_status" class="fa fa-fw fa-sort" ng-click="sortBy('description')"></i></span>
                                    </th>
                                    <th class="sorting">
                                        <span th:text="任务表名"></span>
                                        <span class="pull-right"><i id="id_sort_icon_createDate" class="fa fa-fw fa-sort" ng-click="sortBy('tcWbeFile')"></i></span>
                                    </th>
                                    <th class="sorting">
                                        <span th:text="发起方"></span>
                                        <span class="pull-right"><i id="id_sort_icon_shipDate" class="fa fa-fw fa-sort" ng-click="sortBy('originator')"></i></span>
                                    </th>
                                    <th class="sorting">
                                        <span th:text="WMS对应表名"></span>
                                        <span class="pull-right"><i id="id_sort_icon_shipAddress" class="fa fa-fw fa-sort" ng-click="sortBy('wmsWbeFile')"></i></span>
                                    </th>
                                    <th class="sorting">
                                        <span th:text="调用函数"></span>
                                        <span class="pull-right"><i id="id_sort_icon_function" class="fa fa-fw fa-sort" ng-click="sortBy('interfaceFunction')"></i></span>
                                    </th>
                                    <th class="sorting" style="width: 200px">
                                        <span th:text="存在问题"></span>
                                        <span class="pull-right"><i id="id_sort_icon_problem" class="fa fa-fw fa-sort" ng-click="sortBy('existProblem')"></i></span>
                                    </th>
                                    <th class="sorting">
                                        <span th:text="说明"></span>
                                        <span class="pull-right"><i id="id_sort_icon_instruction" class="fa fa-fw fa-sort" ng-click="sortBy('instruction')"></i></span>
                                    </th>
                                    <th class="sorting">
                                        <span th:text="转存规则"></span>
                                        <span class="pull-right"><i id="id_sort_icon_rule" class="fa fa-fw fa-sort" ng-click="sortBy('conversionRule')"></i></span>
                                    </th><th class="sorting">
                                    <span th:text="备注"></span>
                                    <span class="pull-right"><i id="id_sort_icon_remark" class="fa fa-fw fa-sort" ng-click="sortBy('remarks')"></i></span>
                                    </th>
                                    <th class="sorting">
                                        <span>编辑</span>
                                    </th>
                                </tr>
                                </thead>
                                <tbody>
                                    <tr ng-repeat="item in task_list">
                                        <td>
                                            <a href="javascript:void(0)" ng-click="openDetails(item,$index,$event)">{{item.taskType}}</a>
                                        </td>
                                        <td>
                                            {{item.description}}
                                        </td>
                                        <td>{{item.tcWbeFile}}</td>
                                        <td>{{item.originator}}</td>
                                        <td>{{item.wmsWbeFile}}</td>
                                        <td>{{item.interfaceFunction}}</td>
                                        <td>
                                            {{item.existProblem}}
                                        </td>
                                        <td>
                                            {{item.instruction}}
                                        </td>
                                        <td>
                                            {{item.conversionRule}}
                                        </td>

                                        <td>
                                            {{item.remarks}}
                                        </td>
                                        <td>
                                            <button class="btn btn-danger"
                                                    ng-click="delTask(item,$event)">删除
                                            </button>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                            <navigation th:include="template::paging">
                            </navigation>
                        </div>
                        <div class="modal fade" id="import_excel_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                            <div class="modal-dialog" role="document">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                        <h4 class="modal-title"></h4>
                                    </div>
                                    <div class="modal-body">
                                        <form id="id_override_form">
                                            <div class="form-group">
                                                <input name="file" type="file" />
                                                <br /><span style="color:red">支持后缀为xlsx的文件</span>
                                            </div>
                                        </form>
                                    </div>
                                    <div class="modal-footer">
                                        <button type="button" class="btn btn-default" data-dismiss="modal" th:text="#{action.close}"></button>
                                        <button type="button" class="btn btn-primary" ng-click="importExcel($event)" th:text="#{action.confirm}"></button>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="modal fade" id="export_excel_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                            <form style="display:none;" action="/download/excel/getImportExcel" id="id_export_import_excel_form">
                                <input type="hidden" id="import_excel_modal_import_template_name" name="filename" value="taskExcel" />
                                <input type="hidden" id="import_excel_modal_import_path_name" name="path" value="path" />\
                            </form>'
                        </div>
                    </div>

                    <!-- /.box -->
                </div>

            </div>

            <!-- /.row -->
        </section>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->
    <navigation th:include="template::footer">

    </navigation>


</div>
<!-- ./wrapper -->






<navigation th:include="template::js">

</navigation>
<script th:inline="javascript">

    /*<![CDATA[*/
    angular.module("pls").controller("fzldInterfaceTaskController", function($scope, httpService, Message, $timeout, $rootScope) {
        $scope.task_list = [];
        $scope.search = { };
        pagingScope($scope, {"taskType" : false, "description" : false, "tcWbeFile" : false, "originator" : false, "wmsWbeFile" : false, "interfaceFunction" : false, "existProblem":false,"instruction":false,"conversionRule":false,"remarks":false});
        $scope.importShow = function (event) {
            angular.element("#import_excel_modal").modal("show");
        }
        $scope.importExcel = function (event) {
            var formData = new FormData($("#id_override_form")[0]);
            $.ajax({
                url : "/excelManage/details/importExcel",
                type : "POST",
                data : formData,
                async : true,
                cache : false,
                contentType : false,
                processData : false,
                success : function(json) {
                    if (json == "success") {
                        $scope.loadItems();
                        angular.element("#import_excel_modal").modal('hide');
                    } else if (json == "exit"){
                        swal("该任务已经存在，不能再次导入");
                        angular.element("#import_excel_modal").modal('hide');
                    }else{
                        alert(json);
                    }
                },
                error : function(json) {
                    alert(json);
                }
            });
        }
        $scope.loadItems = function(){
            console.log($scope.search)
            httpService("/excelManage/header/listByPage",{page : $scope.page, size : $scope.size, sortStr : $scope.sort, sortAscOrDesc : $scope.sortAscOrDesc, 'searchObj' : JSON.stringify($scope.search)},function(json){
                $scope.task_list = json.content;
                $scope.pagination = getPagination(json, $scope.page);
            });
        }
        $scope.delTask = function (item,event) {
            httpService("/excelManage/header/remove", {id:item.id},function(json) {
                $scope.loadItems();
            });
        }
        $scope.resetSearch = function (event) {
            $scope.search = { };
        }
        $scope.doSearch = function () {
            $scope.loadItems();
        }
        $scope.openDetails = function (item,index,event) {
            window.location.href="/excelManage/show/"+item.id;
        }
        $scope.exportImportExcel = function() {
            $("#id_export_import_excel_form").submit();
        }
        $scope.init = function() {
            $scope.loadItems();
        }
        $scope.init();

    });
    /*]]>*/
</script>
</body>
</html>